import React, { useEffect } from 'react'
import {Menu} from 'antd'
import withRouter from '@/hoc/withRouter'
import { useDispatch, useSelector } from 'react-redux'
import {getMenusAsync,getRoutesAsync} from '@/store/modules/auth'
function NavigateMenu(props) {
  const menuItems=useSelector((state)=>{
    return state.auth.menus
  })
  const dispatch=useDispatch()
  useEffect(()=>{
    dispatch(getMenusAsync)
    dispatch(getRoutesAsync)
  },[])
  const go=(arg)=>{
    console.log('arg',arg);
    props.nav(arg.key)
  }
  return (
    <div>
        <div style={{
            display:'flex',
            justifyContent:'center',
            padding:'20px 10px'
        }}>
            <img src="http://api.java.crmeb.net/crmebimage/operation/2021/07/13/834580d86f1c43529247fedf3c4304a51twgcts5bs.png" alt="" />
        </div>
        <Menu
            items={menuItems}
            mode="inline"
            theme='dark'
            onClick={go}>
        </Menu>
    </div>
  )
}
export default withRouter(NavigateMenu)